package com.wanqh.reptitle.config;

import lombok.extern.slf4j.Slf4j;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@Slf4j
public class SeleniumConfig {

    @Bean(name = "firefoxWebDriver")
    public WebDriver firefoxWebDriver() {
        String osName = System.getProperties().getProperty("os.name");
        String driverName = "geckodriver";
        if(osName.contains("Windows")) {
            driverName = "geckodriver.exe";
        }
        System.setProperty("webdriver.gecko.driver", SeleniumConfig.class.getClassLoader().getResource(driverName).getPath());
        WebDriver driver = new FirefoxDriver();

        return driver;
    }
//
//    @Bean(name = "operaWebDriver")
//    public WebDriver operaWebDriver() {
//        String osName = System.getProperties().getProperty("os.name");
//        String driverName = "operadriver.exe";
//        if(osName.contains("Windows")) {
//            driverName = "operadriver.exe";
//        }
//        System.setProperty("webdriver.opera.driver", SeleniumConfig.class.getClassLoader().getResource(driverName).getPath());
//        WebDriver driver = new FirefoxDriver();
//
//        return driver;
//    }
}
